package com.chengyu.core.config;

import com.chengyu.core.interceptor.FreezeInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {
    @Bean
    public FreezeInterceptor myLoginHandler(){
        return new FreezeInterceptor();
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {


        //拦截的路径一般子在结尾的时候加** 表示所有的。/*是匹配子文件夹
        //拦截所有可以配置为/**
        registry.addInterceptor(myLoginHandler())
                //制定拦截的路径
//                .addPathPatterns("/**")
                .excludePathPatterns("/**");


                //添加不拦截的路径
//                .excludePathPatterns("/login", "/css/**", "/images/**", "/js/**", "/login.html");
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
